﻿namespace HiMap.Carto
{
    using HiMap.Base;
    using HiMap.Style;
    using System;

    public class PointStyleClass : HiMapPtrClass, IPointStyle, IStyle, IHiMapPtr
    {
        public PointStyleClass()
        {
            base.m_InPtr = HiMap.Carto.VC.KWG_POINTSTYLE_CREATE();
            base.m_Used = false;
        }

        internal PointStyleClass(int InPtr, bool Used)
        {
            base.m_InPtr = InPtr;
            base.m_Used = Used;
        }

        public void AddSymbol(IPointSymbol Symbol)
        {
            if (!Symbol.Used)
            {
                HiMap.Carto.VC.KWG_POINTSTYLE_ADD_SYMBOL(base.m_InPtr, Symbol.InPtr);
                Symbol.Used = true;
            }
        }

        ~PointStyleClass()
        {
            if (!base.m_Used && (base.m_InPtr != 0))
            {
                HiMap.Carto.VC.KWG_POINTSTYLE_DELETE(base.m_InPtr);
            }
        }

        public IPointSymbol GetSymbol(int nSymbol)
        {
            int num = HiMap.Carto.VC.KWG_POINTSTYLE_GET_SYMBOL(base.m_InPtr, nSymbol);
            if (num != 0)
            {
                switch (HiMap.Carto.VC.KWG_POINTSYMBOL_GET_TYPE(num))
                {
                    case 1:
                        return new PointSymbolFeatureClass(num, true);

                    case 2:
                        return new PointSymbolBmpClass(num, true);

                    case 3:
                        return new PointSymbolFontClass(num, true);
                }
            }
            return null;
        }

        public bool SetSymbol(int nSymbol, IPointSymbol Symbol)
        {
            if (!Symbol.Used && HiMap.Carto.VC.KWG_POINTSTYLE_SET_SYMBOL(base.m_InPtr, nSymbol, Symbol.InPtr))
            {
                Symbol.Used = true;
                return true;
            }
            return false;
        }

        StyleType IStyle.Type
        {
            get
            {
                return StyleType.PointStyle;
            }
        }

        public int SymbolCount
        {
            get
            {
                return HiMap.Carto.VC.KWG_POINTSTYLE_GET_SYMBOL_COUNT(base.m_InPtr);
            }
        }
    }
}

